<template>
  <div>
    <Breadcrumb></Breadcrumb>
    <h1>会员列表</h1>
    <el-table :data="rows" stripe style="width: 100%">
      <el-table-column prop="_id" label="会员编号" width="280px">
      </el-table-column>

      <el-table-column prop="province" label="地址"></el-table-column>
      <el-table-column prop="gender" label="性别">
        <template slot-scope="scope">
          <span>{{ scope.row.gender == 1 ? "男" : "女" }}</span>
        </template>
      </el-table-column>
      <el-table-column label="会员头像">
        <template slot-scope="scope">
          <el-image
            style="width: 50px; height: 50px"
            :src="scope.row.avatarUrl"
          ></el-image>
        </template>
      </el-table-column>
      <el-table-column prop="vipdate" label="截止时间"> </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="cancelVip(scope.$index, scope.row)"
            >取消会员</el-button
          >
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
// 引入面包屑
import Breadcrumb from "../../commponents/common/Breadcrumb.vue";
// 引入 vip 状态机(混入文件)
import mixinsList from "@/mixins/mixinsList";
export default {
  mixins: [mixinsList("Vip")],
  components: {
    Breadcrumb,
  },
  data() {
    return {
      vip: this.rows,
      dialogVisible: false,
    };
  },
  computed: {},
  methods: {
    //取消会员
    async cancelVip(index, row) {
      const { data } = await this.$api.member.cancelVip({ _id: row._id });
      console.log(data);
      if (data.meta.status == 200) {
        this.$message({
          message: "操作成功",
          type: "success",
        });
        this.getDataAsync();
      } else {
        this.$message.error("操作失败");
      }
    },

    // 删除会员
    async handleDelete(index, row) {
      const data = await this.deleteOnceData({ _id: row._id });
      if (data.meta.status == 200) {
        this.$message({
          message: "删除成功",
          type: "success",
        });
        this.getDataAsync();
      } else {
        this.$message.error("删除失败");
      }
    },
  },
};
</script>

<style></style>
